<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
	google.load("language", "1");
	
	var preferedLanguage = "en"; //Definere en global variabel som bruges til at bestemmer det fortrukne sprog. 
</script>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="cookies.js"></script>
<title>Wolverine Peace Chat</title>
</head>
<body onload="checkNickname()" id="body">
<div id="content-wrapper">
<h3>World Peace Chat</h3>
<div id="chat"></div>
<!-- <input type="text" id="message"/> --> <input type="hidden"
	id="nick" value="" /><br />

<div class="row">
<div class="label">Message:</div>
<div class="item"><textarea rows="4" id="message"></textarea> <input
	id="submit" type="button" value="Send" /></div>
<div class="clear"></div>
</div>
<div class="row">
<div class="label">Prefered Language:</div>
<div class="item"><select id="selection">
	<option value="af">AFRIKAANS</option>
	<option value="sq">ALBANIAN</option>
	<option value="ar">ARABIC</option>
	<option value="be">BELARUSIAN</option>
	<option value="bg">BULGARIAN</option>
	<option value="ca">CATALAN</option>
	<option value="zh">CHINESE</option>
	<option value="zh-CN">CHINESE_SIMPLIFIED</option>
	<option value="zh-TW">CHINESE_TRADITIONAL</option>
	<option value="hr">CROATIAN</option>
	<option value="cs">CZECH</option>
	<option value="da">DANISH</option>
	<option value="nl">DUTCH</option>
	<option value="en" selected="selected">ENGLISH</option>
	<option value="et">ESTONIAN</option>
	<option value="tl">FILIPINO</option>
	<option value="fi">FINNISH</option>
	<option value="fr">FRENCH</option>
	<option value="gl">GALICIAN</option>
	<option value="de">GERMAN</option>
	<option value="el">GREEK</option>
	<option value="ht">HAITIAN_CREOLE</option>
	<option value="iw">HEBREW</option>
	<option value="hi">HINDI</option>
	<option value="hu">HUNGARIAN</option>
	<option value="is">ICELANDIC</option>
	<option value="id">INDONESIAN</option>
	<option value="ga">IRISH</option>
	<option value="it">ITALIAN</option>
	<option value="ja">JAPANESE</option>
	<option value="ko">KOREAN</option>
	<option value="lv">LATVIAN</option>
	<option value="lt">LITHUANIAN</option>
	<option value="mk">MACEDONIAN</option>
	<option value="ms">MALAY</option>
	<option value="mt">MALTESE</option>
	<option value="no">NORWEGIAN</option>
	<option value="fa">PERSIAN</option>
	<option value="pl">POLISH</option>
	<option value="pt">PORTUGUESE</option>
	<option value="pt-PT">PORTUGUESE_PORTUGAL</option>
	<option value="ro">ROMANIAN</option>
	<option value="ru">RUSSIAN</option>
	<option value="sr">SERBIAN</option>
	<option value="sk">SLOVAK</option>
	<option value="sl">SLOVENIAN</option>
	<option value="es">SPANISH</option>
	<option value="sw">SWAHILI</option>
	<option value="sv">SWEDISH</option>
	<option value="tl">TAGALOG</option>
	<option value="th">THAI</option>
	<option value="tr">TURKISH</option>
	<option value="uk">UKRAINIAN</option>
	<option value="vi">VIETNAMESE</option>
	<option value="cy">WELSH</option>
	<option value="yi">YIDDISH</option>
</select></div>
<div class="clear"></div>
</div>
</div>
<script type="text/javascript">

	//Funktion til at tilføje eventlistener til et objekt. 
	function addEventListener(myNode, eventType, myHandlerFunc) {
		if (myNode.addEventListener)
			myNode.addEventListener(eventType, myHandlerFunc, false);
		else
			myNode.attachEvent("on" + eventType, function(event) {
				myHandlerFunc.call(myNode, event);
			});
	}

	//Funktion til at stoppen et event igen. 
	function stopEvent(event) {
		if (navigator.appName == "Microsoft Internet Explorer") {
			event.returnValue = false;
		} else {
			event.preventDefault();
		}
	}

	//Funktion til at håndtere keyEvents på en besked i chatten. 
	function keyEvent(event) {
		if (event.keyCode == 13) { //Vi reagere kun på ENTER, hvor vi submitter beskeden.
			formSubmission();
			stopEvent(event);
		}
	}

	//Funktion til at skrifte det fortrukne sprog. 
	function changePreferedLanguage(event) {
		preferedLanguage = document.getElementById("selection").value; //Sætter det fortrukne sprog til at være det valgte i select boksen.
	}

	addEventListener(document.getElementById("submit"), "click", formSubmission); //Tilføjer onClick EventListener til send knappen
	addEventListener(document.getElementById("message"), "keypress", keyEvent); //Tilføjer onKeypress EventListener til besked input feltet
	addEventListener(document.getElementById("selection"), "change", changePreferedLanguage); //Tilføjer onChange EventListener select boksen
</script>
</body>
</html>